#!/bin/sh

if test "$1" != "start"
then
  exit 0
fi

# sixad
mkdir -p /var/lib/sixad/profiles
cp /etc/sixad.profile /var/lib/sixad/profiles/default

# custom network config
mkdir -p "/var/lib/connman"
ln -sf "/userdata/system/network-connman.config" "/var/lib/connman/batocera-custom.config"
ln -sf "/boot/network-connman.config" "/var/lib/connman/batocera-boot-custom.config"

# bluetooth
mkdir -p /var/lib/bluetooth

# samba
mkdir -p /var/lib/samba/private
chmod 0755 /var/lib/samba
mkdir -p /var/cache

# dbus
mkdir -p /var/lib/dbus

# Udev custom rules
mkdir -p /run/udev/

# xorg
mkdir -p /var/log

# ensure some holders are available
mkdir -p /var/tmp
mkdir -p /var/opt

# populate the ld cache
mkdir -p /etc
cat << EOF > /etc/ld.so.conf
/usr/lib
/lib
/lib32
/usr/lib/mangohud
EOF
# detached for perf issue (boot time)
ldconfig &
